package mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.example.bean.HomePostsInfo;
import org.example.bean.MemberInfo;
import org.example.bean.ReplyPostsInfo;

import java.util.List;

public interface HomePostsMapper {
    @Select("select * from homeposts where forumId=#{id}")
    List<HomePostsInfo> findHomePostsByForumsId(int id);
    @Insert("INSERT INTO homeposts VALUES(null,#{userId},#{forumId},#{homePostTitle},1,now(),#{homePostContexts},#{sayMood})")
    void saveHomePosts(HomePostsInfo hpi);
    @Select("select * from homeposts where homePostId=#{id}")
    HomePostsInfo findHomePostById(int id);
    @Select("select * from replyposts where homepostid=#{id}")
    List<ReplyPostsInfo> findReplyPostsByHomePostId(int id);
    @Insert("insert into replyposts values(NULL,#{userId},#{replyPostContexts},NOW(),#{homePostId},1)")
    void saveReply(ReplyPostsInfo rpi);
    @Select("select * from Member where userId=#{userId}")
    MemberInfo findMemberByUserId(int userId);
    @Update("update Member set integral=#{integral} where userId=#{userId}")
    void saveMemberByUserId(MemberInfo mi);
    @Update("update users set id=#{id} where userId=#{userId}")
    void saveUserById(@Param("id")int id,@Param("userId") int userId);
}
